# Maintainer: Marian Buschsiewke <marian.buschsieweke@ovgu.de>
# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=qscintilla
pkgver=2.13.3
pkgrel=0
pkgdesc="QScintilla is a port to Qt of Neil Hodgson's Scintilla C++ editor control"
url="https://www.riverbankcomputing.com/software/qscintilla"
arch="all"
license="GPL-3.0-only"
subpackages="
	$pkgname-designer:designer
	$pkgname-dev
	"
makedepends="
	qt5-qtbase-dev
	qt5-qttools-dev
	py3-pyqt-builder
	py3-ply
	py3-sip
	python3-dev
	"
source="https://www.riverbankcomputing.com/static/Downloads/QScintilla/$pkgver/QScintilla_src-$pkgver.tar.gz"
builddir="$srcdir/QScintilla_src-$pkgver"

# py3-qscintilla is blocked by py3-qt5 on armhf
_with_python3_bindings="yes"
case "$CARCH" in
	armhf) ;;
	*)
		makedepends="$makedepends py3-qt5"
		subpackages="$subpackages py3-$pkgname:py3"
		_with_python3_bindings="no"
		;;
esac

build() {
	cd $builddir/src
	qmake-qt5
	make

	cd $builddir/designer
	qmake-qt5 INCLUDEPATH+=../src QMAKE_LIBDIR+=../src
	make

	if [ "$_with_python3_bindings" != "yes" ]; then
		cd $builddir/Python
		mv pyproject-qt5.toml pyproject.toml
		sip-build \
			--no-make \
			--qmake /usr/bin/qmake-qt5 \
			--qsci-features-dir ../src/features \
			--qsci-include-dir ../src \
			--qsci-library-dir ../src \
			--api-dir /usr/share/qt/qsci/api/python
		cd build
		make
	fi
}

check() {
	cd $builddir/src
	make check
}

package() {
	cd $builddir/src
	make DESTDIR="$pkgdir" INSTALL_ROOT="$pkgdir" install
}

designer() {
	pkgdesc="$pkgname (Qt5 designer plugin)"
	depends="qscintilla"

	cd $builddir/designer
	make DESTDIR="$subpkgdir" INSTALL_ROOT="$subpkgdir" install
}

py3() {
	pkgdesc="$pkgname (Python3 bindings)"
	depends="py3-qt5"

	cd $builddir/Python/build
	make DESTDIR="$subpkgdir" INSTALL_ROOT="$subpkgdir" install
}
sha512sums="
be102fd6123fad0bc7f8de39080886369398889de48a4ec8873a0751890d7be1f238ae5194b71d31aac492e2881b6bf7885d9c06a2a47e36328780b47694f5b5  QScintilla_src-2.13.3.tar.gz
"
